<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::get('/', function()
{
    return View::make('hello');
});

Route::patterns([
    'id'         => '[1-9][0-9]*',
    'comment_id' => '[1-9][0-9]*',
    'type'       => 'weibo|qq|weixin',
]);

Route::group(array('prefix' => 'v2'), function()
{
    Route::get('generate_token', 'MultiplexController@generate_token');
    Route::get('generate_captcha', 'MultiplexController@generateCaptcha');
    // 首页-文章
    Route::get('articles', 'ArticleController@index');
    // 报告
    Route::get('reports', 'ArticleController@report');
    // 文章-正文
    Route::get('articles/{id}', 'ArticleController@show');
    // 文章评论列表
    Route::get('articles/{id}/comments', 'ArticleController@commentList');
    // 文章评论
    Route::post('articles/{id}/comments', 'ArticleController@comment');
    // 文章搜索
    Route::get('search/articles', 'ArticleController@search');
    // 团队
    Route::get('teams', 'ArticleController@team');
    // 产品
    Route::get('products', 'ArticleController@product');
    // 用户注册
    Route::post('users', 'UserController@store');
    // 用户登录
    Route::post('oauth/access-token', 'OAuthController@postAccessToken');
    // 获取当前用户的信息
    Route::get('user', 'UserController@show');
    // 我的评论
    Route::get('user/comments', 'UserController@myComment');
    // 我的收藏
    Route::get('user/stars', 'UserController@myStar');
    // 我的消息
    Route::get('user/informations', 'UserController@myInformation');
    // 文章评论点赞
    Route::put('articles/{id}/comments/{comment_id}/favours', 'CommentController@favour');
    // 文章评论取消点赞
    Route::delete('articles/{id}/comments/{comment_id}/favours', 'CommentController@unfavour');
    // 文章评论的回复
    Route::post('articles/{id}/comments/{comment_id}/replies', 'CommentController@reply');
    // 匿名用户回复文章评论
    Route::post('articles/{id}/comments/{comment_id}/anonymous_replies', 'CommentController@anonymousReply');
    // 收藏文章
    Route::put('articles/{id}/stars', 'ArticleController@star');
    // 取消收藏文章
    Route::delete('articles/{id}/stars', 'ArticleController@unstar');
    // 修改用户的个人信息
    Route::post('user', 'UserController@modify');
    // 首页-更多
    Route::get('more_articles/{id}', 'ArticleController@moreArticle');
    // 第三方登录
    // 新浪微博第三方登录相关路由
    Route::get('weibo_url', 'ThirdPartyLoginController@generateWeiboUrl');
    // qq 第三方登录相关路由
    Route::get('qq_url', 'ThirdPartyLoginController@generateQqUrl');
    // weixin 网页授权相关路由
    Route::get('weixin_url', 'ThirdPartyLoginController@generateWeixinUrl');
    // 第三方登录回调
    Route::get('callbacks/{type}', 'ThirdPartyLoginController@callback');
    // 根据用户传递过来的 token 获取用户的凭证
    Route::get('entry', 'ThirdPartyLoginController@entry');
    // 联系方式
    Route::get('contacts', 'ArticleController@contact');
    // 修改用户密码
    Route::put('user/password', 'UserPasswordController@modify');
    // 发送验证邮件
    Route::post('send/emails', 'UserPasswordController@sendEmail');
    // 重置用户的密码
    Route::put('reset/password', 'UserPasswordController@reset');
    // 社区标签
    Route::get('tags', 'CommunityController@tag');
    // 社区评论
    Route::get('article_comments/{tags}', 'CommunityController@getCommentsByTags')
        ->where('tags', '([1-9][0-9]*,)+');
    // 用户退出登录 api
    Route::delete('oauth/invalidate-token', 'UserController@logout');
    //
    Route::get('users/{unique_id}/entry', 'UserController@fetchEntry');
});
